/**
 * 
 */
package com.antilia.infomaresme.data.services.impl;

import com.antilia.infomaresme.data.dao.interfaces.IUsersDao;
import com.antilia.infomaresme.data.dataobjects.User;
import com.antilia.infomaresme.data.services.IAuthenticator;
import com.google.inject.Inject;

/**
 * @author Ernesto
 *
 */
public class Authenticator implements IAuthenticator {

	private IUsersDao usersDao;
	
	@Inject
	public Authenticator(IUsersDao usersDao) {
		this.usersDao = usersDao;
	}
	
	/* (non-Javadoc)
	 * @see com.antilia.infomaresme.data.services.IAuthenticator#authenticate(java.lang.String, java.lang.String)
	 */
	public User authenticate(String username, String password) {
		User user = usersDao.loadById(username);
		if(user != null) {
			if(user.getPasword().equals(password)) {
				return user;
			}
		}
		return null;
	}

}
